<?php

/**
 * [kkyoo_admin] (C)2007 aodian Co,Ltd.
 * @File: left.php
 */

ob_start();
session_start();
$log_array = array ();
$qstr = null;

require_once ('library/config.inc.php');
require_once ('library/global.func.php');
require_once ('library/admin.class.php');

// ---------- safe check ----------
checkLogin();
// ---------- safe check ----------

// ---------- assignment session variable ----------
$aID 	= $log_array['id'];
$aUser 	= $log_array['user'];
$aName 	= $log_array['name'];
$aPid 	= $log_array['pid'];
$aSPid 	= $log_array['spid'];
// ---------- assignment session variable ----------
// ---------- template init ----------
$template = 'left.tpl';
// ---------- template init ----------
require_once ('library/smarty.inc.php');
if (!$smarty->is_cached($template, $qstr)) { // 
	require_once (CONN_PATH);
	// ---------- common smarty assign ----------
	$smarty->assign('aID', $aID);
	$smarty->assign('aUser', $aUser);
	$smarty->assign('aName', $aName);
	if ($aID == 1) {
		$aPid = 'NULL';
		$aSPid = 'NULL';
	}
	// ---------- common smarty assign ----------
	$admin = new admin($conn);
	$result = $admin->getLevel($aPid, 'NULL', 'NULL', '', 1, 'level');
	$resultCnt = $result['cnt'];
	for ($i = 0; $i < $resultCnt; $i++) {
		$menu[$i]['id'] = $result[$i]['id'];
		$menu[$i]['menu'] = $admin->getLevel($aSPid, $result[$i]['id'], 'NULL', '', 1, 'sublevel');
		$menu[$i]['name'] = $result[$i]['name'];
		unset ($menu[$i]['menu']['cnt']);
	}
	$smarty->assign('menu', $menu);
	unset($admin);
	require_once ('close.inc.php');
	// ---------- display --------------------
	$smarty->display($template, $qstr);
} else {
	// ---------- display --------------------
	$smarty->display($template, $qstr);
}
?>